<template>
  <el-table
    :data="
      tableData
    "
    :stripe="stripe"
    :current-page.sync="currentPage"
    style="width: 100%"
  >
  <el-table-column width="150" prop="desp" label="区划" >
  </el-table-column>
    <el-table-column width="350" prop="jgname" label="机构名称" >
    </el-table-column>
 <el-table-column width="180" prop="jgsySystemCode" label="系统类别" >
 </el-table-column>
 <el-table-column width="180" prop="jgtype" label="机构类型" >
 </el-table-column>
 
  </el-table>
  <div class="pagination">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-sizes="[10, 15, 20]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>
<script>
import Sever from "@/api/selfApi.js";
export default {
  props: ["depCode", "depName"],
  data() {
    return {
    
      stripe: true, //是否为斑马纹 table
      tableData: [],
      currentPage: 1,
      pagesize: 10,
      total: 0,
    };
  },
  methods: {
    handleSizeChange(val) {
      this.pagesize = val;
	   this.refreshData(this.depCode, this.depName,this.currentPage,this.pagesize);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
	   this.refreshData(this.depCode, this.depName,this.currentPage,this.pagesize);
    },
    async refreshData(depCode, depName,currentPage,pagesize) {
		
      if (depCode == "") {
        depCode = "36%";
      }
      if (depName == "党委") {
       depName = "dw";
      } else if (depName == "人大") {
       depName = "rd";
      }  else if (depName == "政府") {
       depName = "zf";
      }  else if (depName == "政协") {
       depName = "zx";
      }  else if (depName == "法院") {
      depName = "fy";
      }  else if (depName == "检察院") {
       depName = "jcy";
      }  else if (depName == "群团") {
       depName = "qt";
      }  else if (depName == "民主党派") {
       depName = "mzdp";
      }
      await Sever.smz
        .getXzjgPieChild({ depCode: depCode, depName: depName,pageNum:currentPage,pageSize:pagesize })
        .then((res) => {
          if (res.code == 1) {
            if (res.data != null) {
				console.log(res.data);
              this.tableData = res.data.list;
              this.total = res.data.total;
            } else {
              this.tableData = [];
            }
          } else {
            console.log("getXzjgPieChild接口出错！");
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
  mounted() {
    this.$nextTick(() => {
	
      this.refreshData(this.depCode, this.depName,this.currentPage,this.pagesize);
    });
  },
};
</script>